package com.qys.training.openapi.listener;

import com.hazelcast.core.HazelcastInstance;
import com.qys.training.openapi.sender.AliveSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @author Winstone
 * @date 2020/8/5 - 7:59 下午
 */
@Component
public class ServiceRegistListener implements ApplicationListener<ApplicationStartedEvent> {
    @Autowired
    HazelcastInstance client;

    public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
        String uuid = UUID.randomUUID().toString();
        new Thread(new AliveSender(client,uuid)).start();
    }
}
